import React, { useEffect, useState } from 'react';
import { Select } from 'antd';
import { dictionaryList } from '@/services/dictionary';

const InstitutionType = props => {
    const [list, setList] = useState([]);
    const fetchList = async () => {
        const { code, data } = await dictionaryList({ code: 'institutionType' })
        if (code === 10000 && Array.isArray(data)) {
            setList(data)
        }
    }

    useEffect(() => {
        fetchList()
    }, [])

    return (
        <Select {...props} getPopupContainer={trigger => trigger.parentNode} allowClear>
            {
                list.map(v => (<Select.Option key={v?.dictValue}>{v?.dictName}</Select.Option>))
            }
        </Select>
    )
}

export default InstitutionType;
